package com.googlecode.gwt4gae.client.user;

import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.googlecode.gwt4gae.client.BaseAction;
import com.googlecode.gwt4gae.model.UserAccount;

public class UserAction extends BaseAction {
	private UserAccountServiceAsync userAccountService = GWT.create(UserAccountService.class);
	private UserView view;

	public UserAction() {
	}
	
	@Override
	protected void initialize() {
		view = new UserView(this);
	}

	@Override
	public void handleEvent(AppEvent event) {
		UserAccount userAccount = new UserAccount();
		userAccount.setLoginName("ch");
		userAccount.setPassword("11111");
		userAccountService.persist(userAccount,new AsyncCallback<Void>() {
			public void onFailure(Throwable caught) {
				
			}

			public void onSuccess(Void result) {
				
			}});
		forwardToView(view, event);
	}
}
